package com.code.config;


import org.apache.commons.lang3.StringUtils;

/**
 * 生成代码输出文件配置
 */
public enum OutParentDirEnum {
    /**
     * api.js.vm
     */
    api_js(DataSourceInfo.DRIVER_CLASS.getValue() + "/api.js.vm", "web", "前端js代码"),

    /**
     * api.js.vm
     */
    index_vue(DataSourceInfo.DRIVER_CLASS.getValue() + "/index.vue.vm", "web", "前端index代码"),

    /**
     * xml
     */
    mapper_xml(DataSourceInfo.DRIVER_CLASS.getValue() + "/Mapper.xml.vm", "", "xml"),

    /**
     * 默认目录
     */
    other("", "java", "默认目录"),

    ;

    private String key;
    private String type;
    private String describe;

    public static String getTypeByTemplate(String template) {
        if (StringUtils.isEmpty(template)) {
            return other.getType();
        }
        for (OutParentDirEnum dataSourceDriver : OutParentDirEnum.values()) {
            if (template.equals(dataSourceDriver.getKey())) {
                return dataSourceDriver.getType();
            }
        }
        return other.getType();
    }

    OutParentDirEnum(String key, String type, String describe) {
        this.key = key;
        this.type = type;
        this.describe = describe;
    }

    public String getKey() {
        return key;
    }

    public void setKey(String key) {
        this.key = key;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    public String getDescribe() {
        return describe;
    }

    public void setDescribe(String describe) {
        this.describe = describe;
    }
}
